/*
//输入框
var year = prompt("请输入年份：");
//弹出警示框
if (year % 4 == 0 && year % 100 != 0) {
    alert("输入的是闰年！");
} else {
    // console  控制台输出 程序员测试用的
    console.log("输入的不是闰年！");
}
*/
//-----------------------------------------------
/*
//倒计时前面填0
var time = prompt("请输入一个0~59的数字：");
var result = time < 10 ? "0" + time : time;
alert(result);
*/
//-----------------------------------------------
/*
//switch
var fac = prompt("请输入水果的名字：");
switch (fac) {
    case "苹果":
        alert("苹果4元！");
        break;
}
*/
//-----------------------------------------------
//1-100奇数和偶数和
/*
var even = 0;
var obb = 0;
for (var i = 0; i <= 100; i++) {
    if (i % 2 == 0) {
        even += i;
    } else {
        obb += i
    }
}
alert("1-100偶数和：" + even);
alert("1-100奇数和：" + obb);
*/
//-----------------------------------------------
/*
var num = prompt("请输入班级的同学总数：");
var sum = 0;//求和
var average = 0;//求平均值
for (var i = 0; i <= num; i++) {
    var score = prompt("请输入第" + i + "个学生成绩。");
    sum += parseFloat(score);
}
average = sum / num;
alert("平均成绩为:" + average);
*/
//-----------------------------------------------
//追加字符串
/*
var num = prompt("请输入要打印的个数：")
var str = "";
for (var i = 0; i < num; i++) {
    str += "*";
}
alert(str);
*/
//-----------------------------------------------
//双重for循环
/*
var num = prompt("请输入要打印的个数：")
var str = "";
for (var i = 1; i <= num; i++) {
    for (var j = 1; j <= num; j++) {
        str += "*";
    }
    str += "\n";
}
alert(str);
*/
//-----------------------------------------------
//倒三角
/*
var num = prompt("请i输入要打印的行数：")
var str = "";
for (var i = 1; i <= num; i++) {
    for (var j = i; j <= num; j++) {
        str += "*";
    }
    str += "\n";
}
alert(str);
*/
//-----------------------------------------------
//9*9乘法表
/*
var num = prompt("请输入要打印的乘法：")
var str = "";
for (var i = 1; i <= num; i++) {
    for (var j = 1; j <= i; j++) {
        str += j + "*" + i + "=" + j * i + '\t';
    }
    str += "\n";
}
alert(str);
*/
//-----------------------------------------------
//while
/*
var num = 1;
while (num < 100) {
    alert("hshsjhs");
    num++;
}
*/
//-----------------------------------------------
/*
var massage = prompt("你爱我吗？");
while (massage !== "我爱你") {
    prompt("你爱我吗？")
}
alert("我也爱你鸭！");
*/
//-----------------------------------------------
//Array 数组
/*
// var arr = [true, 2, 3, 4, false, "asda",];
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var sum = 0;
// alert(arr[3]);
// alert(arr);//遍历
//for遍历
for (var i = 0; i < arr.length; i++) {
    // alert(arr[i]);//遍历打印
    sum += arr[i];//加和
}
alert(sum);//求和
alert(sum / arr.length);//平均值
*/
//-----------------------------------------------
//最大值
/*
var arr = [3, 5, 6, 7, 3, 4, 65, 7, 8, 8, 9];
var max = arr[0];
for (var i = 0; i < arr.length; i++) {
    if (arr[i] > max) {
        max = arr[i];
    }
}
alert(max);
*/
//-----------------------------------------------
//链接字符串
/*
var arr = [true, 2, 3, 4, false, "asda",];
var str = "";
for (var i = 0; i < arr.length; i++) {
    str += arr[i] + "||";
}
alert(str)
*/
//-----------------------------------------------
//阶乘
/*
var day = prompt("请输入天数：")
var arr = [];
var sum = 0;
for (var i = 0; i < parseInt(day); i++) {
    arr[i] = i + 1;//依次追加数组元素
    sum += arr[i]
}
alert(sum);
*/
//-----------------------------------------------
//大于22的数组元素
/*
var arr = [11, 22, 33, 44, 55, 66, 3, 2, 1, 4, 6, 7, 7, 8, 7, 65, 4, 33];
var newarr = [];
var j = 0;
for (var i = 0; i < arr.length; i++) {
    if (arr[i] > 22) {
        newarr[j] = arr[i];
        j++;
    }
}
alert(newarr)
*/
//-----------------------------------------------
/*
var arr1 = [11, 22, 33, 44, 55, 66, 3, 2, 1, 4, 6, 7, 7, 8, 7, 65,  4,  33];
var newarr1 = [];
for (var i1 = 0; i1 < arr.length; i1++) {
    if (arr1[i] > 22) {
        newarr1[newarr1.length] = arr[i];
    }
}
alert(newarr)
*/
//-----------------------------------------------
//倒序输出
/*
var arr = [11, 22, 33, 44, 55, 66, 3, 2, 1, 4, 6, 7, 7, 8, 7, 65, 4, 33];
var newarr = [];
for (var i = arr.length - 1; i >= 0; i--) {
    newarr[newarr.length] = arr[i];
}
alert(newarr)
*/
//-----------------------------------------------
//冒泡排序
/*
var arr = [11, 3, 2, 1, 4, 6, 7, 7, 8, 7, 65, 4, 33]; // 数组存储的数据
for (var i = 0; i < arr.length - 1; i++) { // 比较的次数
    for (var j = 0; j < arr.length - 1 - i; j++) { // 前后交换的次数
        if (arr[j] < arr[j + 1]) {  // 判断大小
            var temp = arr[j];  // 若判断的结果为真，则交换两个变量，若为假，直接进行下次比较
            arr[j] = arr[j + 1];
            arr[j + 1] = temp;
        }
    }
}
alert(arr)
*/


/*
var arr = [11, 3, 2, 1, 4, 6, 7, 7, 8, 7, 65, 4, 33];
for (var i = 0; i <= arr.length - 1; i++) {
    for (var j = 0; i <= arr.length - i - 1; i++) {
        if (arr[j] < arr[j + 1]) {
            var temp = arr[j];
            arr[j] = arr[j + 1]
            arr[j + 1] = temp;
        }
    }
}
alert(arr);
*/
